package com.liangzhong.model.trainingcamp.vo
{
	import com.common.utils.Debug;
	import com.liangzhong.model.AppData;
	import com.liangzhong.model.trainingcamp.TrainingCampDataConstant;
	import com.liangzhong.model.trainingcamp.TrainingcampDataManager;
	
	import flash.utils.ByteArray;

	/**
	 *训练营数据 
	 * @author Administrator
	 * 
	 */	
	public class TrainingcampVo
	{
		public function TrainingcampVo()
		{
		}
		/**
		 *俱乐部id 
		 */
		public var clubid     :int;
		/**
		 *训练营等级 
		 */
		public var level      :int;
		
		/**
		 *升级所需欧元 
		 */
		public var coin      :int;
		
		/**
		 *升级所需等级 
		 */
		public var needlevel  :int;
		/**
		 *上次升级时间 
		 */
		public var pretime   :int;
		/**
		 *进攻位开启个数 
		 */
		public var  attack    :int;
		/**
		 *进攻位已训练次数 
		 */
		public var atttime   :int;
		/**
		 *进攻位购买次数 
		 */
		public var attcoin   :int;
		/**
		 *防守位开启个数 
		 */
		public var defence  :int;
		/**
		 *防守位以训练次数 
		 */
		public var deftime :int;
		/**
		 *防守位购买次数 
		 */
		public var defcoin :int;
		/**
		 *抢断位开启个数 
		 */
		public var  steal  :int;
		/**
		 *抢断位已训练次数 
		 */
		public var stetime :int;
		/**
		 *抢断位购买次数 
		 */
		public var stecoin :int;
		/**
		 *力量位开启个数 
		 */
		public var  power :int;
		/**
		 *力量位已训练个数 
		 */
		public var powtime :int;
		/**
		 *力量位购买次数 
		 */
		public var powcoin :int;
		/**
		 *速度位开启个数 
		 */
		public var speed :int;
		/**
		 *速度位已训练个数 
		 */
		public var spetime :int;
		/**
		 *速度位购买次数 
		 */
		public var specoin :int;
		/**
		 *控球位开启个数 
		 */
		public var  control :int;
		/**
		 *控球位已训练次数 
		 */
		public var contime :int;
		/**
		 *控球位购买次数 
		 */
		public var concoin :int;
		/**
		 *冷却时间 秒 
		 */		
		public var freezingTime			:Number = 12 * 60 * 60;
		
		/**
		 *剩余训练次数 
		 */
		public var traincount:int;
		/**
		 *解析数据 
		 * @param $obj
		 * 
		 */
		public function analaysis($obj:Object):void
		{
			for(var str:String in $obj)
			{
				if(this.hasOwnProperty(str))
					this[str] = $obj[str];
				else
					Debug.echo("ClubInformation中没有" + str + "属性");
			}
		}
		/**
		 *更新最大值 
		 * 
		 */
		public function updataMax(buffer:ByteArray):void
		{
			attack = buffer.readByte();
			atttime = buffer.readByte();
			defence = buffer.readByte();
			deftime = buffer.readByte();
			steal = buffer.readByte();
			stetime = buffer.readByte();
			power = buffer.readByte();
			powtime = buffer.readByte();
			speed = buffer.readByte();
			spetime = buffer.readByte();
			control = buffer.readByte();
			contime = buffer.readByte();
		}
		/**
		 *训练一次返回
		 * 
		 */
		public function changeTime(buffer:ByteArray):void
		{
			switch(buffer.readByte())
			{
				case TrainingcampDataManager.ATTACK:
					atttime = AppData.getInstance().time
					break;
				case TrainingcampDataManager.DEFENCE:
					deftime = AppData.getInstance().time
					break;
				case TrainingcampDataManager.STEAL:
					stetime =  AppData.getInstance().time
					break;
				case TrainingcampDataManager.POWER:
					powtime =  AppData.getInstance().time
					break;
				case TrainingcampDataManager.SPEED:
					spetime =  AppData.getInstance().time
					break;
				case TrainingcampDataManager.CONTROL:
					contime =  AppData.getInstance().time
					break;
			}
			traincount = buffer.readInt();
		}
		/**
		 *增加训练次数 
		 * 
		 */
		public function addTrainingCount(value:int):void
		{
			traincount = value;
		}
		/**
		 *清除冷却时间 
		 * @param type
		 * 
		 */
		public function clearTime(type:int):void
		{
			switch(type)
			{
				case TrainingcampDataManager.ATTACK:
					atttime = 0;
					break;
				case TrainingcampDataManager.DEFENCE:
					deftime = 0;
					break;
				case TrainingcampDataManager.STEAL:
					stetime =  0;
					break;
				case TrainingcampDataManager.POWER:
					powtime =  0;
					break;
				case TrainingcampDataManager.SPEED:
					spetime =  0;
					break;
				case TrainingcampDataManager.CONTROL:
					contime =  0;
					break;
			}
		}
		
	}
}